
#ifndef __QE_TIMER_H__
#define __QE_TIMER_H__



#include "qe_device.h"



struct qe_timer_device;
typedef struct qe_timer_device qe_timer_dev;

typedef void (*qe_timer_callback)(qe_timer_dev *);

typedef struct
{
	qe_u32 (*enable_irq)(qe_timer_dev *, qe_bool);
	qe_u32 (*start)(qe_timer_dev *, qe_u32 timeout);
	void (*stop)(qe_timer_dev *);
	qe_u32 (*elapsed)(qe_timer_dev *);
	qe_u64 (*elapsed_ns)(qe_timer_dev *);
} qe_timer_ops;

typedef struct qe_timer_device
{
	qe_dev dev;
	const qe_timer_ops *ops;
	qe_timer_callback callback;
	void *callback_args;
} qe_timer_dev;



qe_ret
qe_timer_set_callback(qe_timer_dev *timer, qe_timer_callback callback, void *args);

qe_ret
qe_timer_start(qe_timer_dev *timer, qe_u32 timeout);

void
qe_timer_stop(qe_timer_dev *timer);

qe_u32
qe_timer_elapsed(qe_timer_dev *timer);

qe_u64 
qe_timer_elapsed_ns(qe_timer_dev *timer);

qe_ret 
qe_timer_register(qe_timer_dev *timer, qe_const_str name, qe_timer_ops *ops, void *priv);



#endif /* __QE_TIMER_H__ */

